<?php
/*sink_cup
2009-4-16 21:08:03 UTC+8
*/
$user_lang=strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
$default_lang_language=substr($user_lang,0,2);
$default_lang_region=substr($user_lang,3,2);
if($default_lang_language=='zh')
{	$my_lang='zh-cn';
	if($default_lang_region=='tw')
		$my_lang='zh-tw';
}
else
	$my_lang='en';
include "./language/$my_lang/index.php";

include './config.php';
$acct_username=$_GET['PlayerName'];
if(empty($_GET['game']))
	$game='W3XP';
else
	$game=$_GET['game'];
$pvpgn_bnet=$prefix.'bnet';
$pvpgn_record=$prefix.'record';
$pvpgn_profile=$prefix.'profile';
$result=$conn->query("SELECT uid,acct_lastlogin_time FROM $pvpgn_bnet WHERE acct_username='$acct_username'");
if($rows=$result->fetch_row())
{
	$uid=$rows[0];
	$acct_lastlogin_time=$rows[1];
	$result->free();
}
$W3XP_random_wins=0;
$W3XP_random_losses=0;
$W3XP_humans_wins=0;
$W3XP_humans_losses=0;
$W3XP_orcs_wins=0;
$W3XP_orcs_losses=0;
$W3XP_undead_wins=0;
$W3XP_undead_losses=0;
$W3XP_nightelves_wins=0;
$W3XP_nightelves_losses=0;
$W3XP_total_wins=0;
$W3XP_total_losses=0;
$result=$conn->query("SELECT W3XP_userselected_icon,W3XP_random_wins,W3XP_random_losses,W3XP_humans_wins,W3XP_humans_losses,W3XP_orcs_wins,W3XP_orcs_losses,W3XP_undead_wins,W3XP_undead_losses,W3XP_nightelves_wins,W3XP_nightelves_losses FROM $pvpgn_record WHERE uid='$uid'");
if($rows=$result->fetch_row())
{
	$icon=$rows[0];
	$W3XP_random_wins=$rows[1];
	$W3XP_random_losses=$rows[2];
	$W3XP_humans_wins=$rows[3];
	$W3XP_humans_losses=$rows[4];
	$W3XP_orcs_wins=$rows[5];
	$W3XP_orcs_losses=$rows[6];
	$W3XP_undead_wins=$rows[7];
	$W3XP_undead_losses=$rows[8];
	$W3XP_nightelves_wins=$rows[9];
	$W3XP_nightelves_losses=$rows[10];
	$result->free();
}
if(empty($icon))
{
	$icon='1D3W';
}
if(empty($W3XP_random_losses))
{
	if(empty($W3XP_random_wins))
		$W3XP_random_per=0;
	else
		$W3XP_random_per=100;
}
else
	$W3XP_random_per=$W3XP_random_wins/($W3XP_random_wins+$W3XP_random_losses);
if(empty($W3XP_humans_losses))
{
	if(empty($W3XP_humans_wins))
		$W3XP_humans_per=0;
	else
		$W3XP_humans_per=100;
}
else
	$W3XP_humans_per=$W3XP_humans_wins/($W3XP_humans_wins+$W3XP_humans_losses);
if(empty($W3XP_orcs_losses))
{
	if(empty($W3XP_orcs_wins))
		$W3XP_orcs_per=0;
	else
		$W3XP_orcs_per=100;
}
else
	$W3XP_orcs_per=$W3XP_orcs_wins/($W3XP_orcs_wins+$W3XP_orcs_losses);
if(empty($W3XP_undead_losses))
{
	if(empty($W3XP_undead_wins))
		$W3XP_undead_per=0;
	else
		$W3XP_undead_per=100;
}
else
	$W3XP_undead_per=$W3XP_undead_wins/($W3XP_undead_wins+$W3XP_undead_losses);
if(empty($W3XP_nightelves_losses))
{
	if(empty($W3XP_nightelves_wins))
		$W3XP_nightelves_per=0;
	else
		$W3XP_nightelves_per=100;
}
else
	$W3XP_nightelves_per=$W3XP_nightelves_wins/($W3XP_nightelves_wins+$W3XP_nightelves_losses);
if(empty($W3XP_total_losses))
{
	if(empty($W3XP_total_wins))
		$W3XP_total_per=0;
	else
		$W3XP_total_per=100;
}
else
{
	$W3XP_total_wins=$W3XP_humans_wins+$W3XP_orcs_wins+$W3XP_orcs_wins+$W3XP_nightelves_wins;
	$W3XP_total_losses=$W3XP_humans_losses+$W3XP_orcs_losses+$W3XP_orcs_losses+$W3XP_nightelves_losses;
	$W3XP_total_per=$W3XP_total_wins/($W3XP_total_wins+$W3XP_total_losses);
}
$result=$conn->query("SELECT location,description,clanname FROM $pvpgn_profile WHERE uid='$uid'");
$location='';
$description='';
$clanname='';
$clanname='';
if($rows=$result->fetch_row())
{
	$location=$rows[0];
	$description=$rows[1];
	$clanname=$rows[2];
	$result->free();
}
include './themes/default/player.tpl';

?>